package TeacherAdmin;

import org.junit.jupiter.api.*;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.CsvFileSource;
import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;

import static java.lang.Thread.sleep;
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
public class ScrollTest extends Init {
    @ParameterizedTest
    @CsvFileSource(resources = "../test.csv")//要有对应的文件test.csv
    @Order(1)
    void login(String name,String password) throws InterruptedException {
        System.out.println("username:"+name);
        System.out.println("password:"+password);
        //输入账号密码
        webDriver.findElement(By.cssSelector("#login > div.logIn-inner > div.right-con.fr > div > div.login-form > form > div:nth-child(1) > div > div > input")).sendKeys(name);
        webDriver.findElement(By.cssSelector("#login > div.logIn-inner > div.right-con.fr > div > div.login-form > form > div:nth-child(2) > div > div > input")).sendKeys(password);
        //点击登录
        webDriver.findElement(By.cssSelector("#login > div.logIn-inner > div.right-con.fr > div > div.login-form > form > div:nth-child(3) > div > button")).click();
        webDriver.manage().window().maximize();
        sleep(3000);

        String curUrl = webDriver.getCurrentUrl();
        Assertions.assertEquals("http://192.168.63.227:10001/digitrain/login/toIndex#/home",curUrl);
        sleep(3000);
    }
    @Test
    @Order(2)
    void scrollTest() throws InterruptedException {
        //验证滚动条
        sleep(3000);
        ((JavascriptExecutor)webDriver).executeAsyncScript("$('#app > section > main').scrollTop = 10000");
    }
}
